package com.example.demo.thread.atomic;

/**
 * Description: 线程安全问题验证<br/>
 *
 * @author liulonglong
 * @taskId <br/>
 * @Date 2019/12/17 18:18
 * @Version 1.0
 */
public class ThreadSafeVerify implements Runnable {

    /**
     * 静态变量
     */
    static Integer a;

    @Override
    public void run() {
        a = 3;
        System.out.println("当前线程：" + Thread.currentThread().getName() + ",a=" + a);
        a = 5;
        System.out.println("当前线程：" + Thread.currentThread().getName() + ",a * 2=" + a * 2);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10000; i++) {
            new Thread(new ThreadSafeVerify(), "Thread-" + i).start();
        }
    }
}
